<#if roles.canManageBid && roles.canCreateBid>
<div class="col-md-12">
	<div class="panel panel-primary">
		<div class="panel-heading">
			<h3 class="panel-title">
				<i class="icon-retweet icon-large"></i>
				7日内需要回收的投标保证金
			</h3>
		</div>
		<#if backTbbzj??>
		<table class="table table-hover table-striped">
			<thead>
				<tr>
					<th class="text-center" width="55"></th>
					<th class="text-center">金额</th>
					<th class="text-center">单位</th>
					<th class="text-center" width="95">回收日期</th>
					<th class="text-center" width="190">项目编号</th>
					<th class="text-center" width="160">项目名称</th>
				</tr>
			</thead>
			<#list backTbbzj as m>
			<tr style="cursor: pointer;" class="open-row-of-tbbzj" data-bid="${m.bid.id}">
				<td class="text-center">
					<div class="btn btn-xs btn-danger back-tbbzj" data-id="${m.id}">收回</div>
				</td>
				<td class="text-center cell-for-open">${(m.total?string('currency'))!'-'}</td>
				<td class="text-center cell-for-open">${m.source}</td>
				<td class="text-center cell-for-open">${(m.backTime?string('yyyy-MM-dd'))!'-'}</td>
				<td class="text-center cell-for-open">${m.bid.projectNo}</td>
				<td class="text-center cell-for-open">${m.bid.name}</td>
			</tr>
			</#list>
		</table>

		<script type="text/javascript">
			require([ 'suredy' ], function() {
				// 打开招标
				$('tr.open-row-of-tbbzj').on('click', '.cell-for-open', function() {
					var id = $(this).parent().data('bid');
					window.open('${request.contextPath}/bid/view/' + id, '_blank');
				});

				// 回收投标保证金
				$('div.btn.back-tbbzj').on('click', function() {
					if (!window.confirm('确认【回收投标保证金】？'))
						return false;

					var $this = $(this);
					var tr = $this.parents('tr');
					var id = $this.data('id');
					var bid = tr.data('bid');

					$.ajax({
						url : '${request.contextPath}/bid-money/gave-back-money/' + bid + '/' + id,
						type : 'post',
						dataType : 'json',
						success : function(result, textStatus, jqXHR) {
							if (!result || !result.success) {
								var msg = (result && result.msg) || '操作失败！';
								alert(msg);
								return false;
							}

							Suredy.loadContent('${request.contextPath}/front-page');
						},
						error : function(jqXHR, textStatus, errorThrown) {
							alert('操作失败！\n\n' + errorThrown);
						}
					});
				});
			});
		</script>
		<#else>
		<div class="panel-body text-danger">暂无数据！</div>
		</#if>
	</div>
</div>
</#if>
